package com.csp.base.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.csp.base.model.JobRunHistory;

/**
 * @author taoken
 *  定时任务记录操作mapper
 */
@Mapper
public interface JobRunHistoryMapper {
	
	/**
	 * 添加记录
	 * @param history
	 */
	@Insert(
			"INSERT INTO job_run_history "+
			"(job_name,job_group_name,job_class_name,run_status,message,HOST,PORT,create_time) "+
			"VALUES "+
			"(#{h.jobName},#{h.jobGroupName},#{h.jobClassName},#{h.runStatus},#{h.message},#{h.host},#{h.port},#{h.createTime})"
			)
	void insertJobRunHistory(@Param("h")JobRunHistory history);

	/**
	 * 列表查询
	 * @param pageNum
	 * @param pageSize
	 * @return
	 */
	@Select(
			"SELECT "+
			"id,job_name jobName,job_group_name jobGroupName,job_class_name jobClassName,"+
			"run_status runStatus,message message,host,port,create_time createTime "+
			"FROM job_run_history "+
			"WHERE "+
			"job_name=#{jobName} AND job_group_name=#{jobGroupName} AND job_class_name=#{jobClassName} ORDER BY create_time DESC "
			)
	List<JobRunHistory> findJobRunHitoryList(@Param("jobName") String jobName,
											 @Param("jobGroupName") String jobGroupName,
											 @Param("jobClassName") String jobClassName);

}
